package cn.wygandwdn.core.failover;

import cn.wygandwdn.common.message.RpcRequest;
import cn.wygandwdn.core.transport.client.RpcClient;
import io.netty.util.concurrent.Promise;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;

/**
 * @description:    超时重试
 * @author: WYG
 * @time: 2021/11/1 21:27
 */

public interface FailoverRetry {

    /**
     * 当发生超时异常时进行重试
     * @param client    客户端
     * @param promise   存放请求结果
     * @param request   实际请求内容
     * @return          请求结果
     */
    Object timeoutRetry(RpcClient client, Promise<Object> promise, RpcRequest request) throws ExecutionException, InterruptedException, TimeoutException;
}
